package com.bsoft.gol.hcb.service.templateSheet.rpc.impl;

import ctd.net.rpc.Client;
import lombok.extern.slf4j.Slf4j;
import com.bsoft.gol.hcb.service.templateSheet.rpc.IMcVisitRpcService;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class McVisitRpcServiceImpl implements IMcVisitRpcService {
    @Override
    public String mcVisitRecord(String serviceMethod,String xml,String service) throws Exception {
        xml = getSoapXml(service,xml);
        log.info("请求："+xml);
        String resp = (String) Client.rpcInvoke("hcnInterface.mcVisitService", "mcVisitRecord", serviceMethod,xml);
        log.info("响应："+resp);
        return resp;
    }

    public static String getSoapXml(String service, String xml) {
        return "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ws=\"http://ws" +
                ".access.hai/\">\n" +
                "   <soapenv:Header/>\n" +
                "   <soapenv:Body>\n" +
                "      <ws:invoke>\n" +
                "         <service>" + service + "</service>\n" +
                "         <urid></urid>\n" +
                "         <pwd></pwd>\n" +
                "         <parameter><![CDATA[" + xml + "]]></parameter>\n" +
                "      </ws:invoke>\n" +
                "   </soapenv:Body>\n" +
                "</soapenv:Envelope>";
    }
}
